package data

import (
	"k8s.io/client-go/kubernetes"
	"k8s.io/client-go/tools/clientcmd"
	"learn/k8s/internal/config"
)

func (d *Data) initK8s(val *config.K8s) (err error) {
	conf, err := clientcmd.BuildConfigFromFlags("", val.Path)
	if err != nil {
		return err
	}
	clientset, err := kubernetes.NewForConfig(conf)
	if err != nil {
		return err
	}
	d.k8s = clientset
	return nil
}
